<template>
  <div class="tnbhzsf" :class="isTopDialog ? 'pointer' : ''" v-if="!isLoading">
    <p class="top">
      <span style="font-weight: 700; font-size: 16px; color: #000">{{
        info.residentName
      }}</span>
      <span style="display: inline-block; margin: 0 20px"
        >证件号：{{ info.idNo }}</span
      >
      <span>填表人：{{ info.createUserId }}</span>
    </p>
    <div class="box">
      <span>随访日期：</span>
      <el-date-picker
        v-model="info.visitDate"
        align="right"
        type="date"
        placeholder="选择随访日期"
        :picker-options="pickerOptions"
        size="small"
      >
      </el-date-picker>
    </div>
    <div class="box">
      <span>随访方式：</span>
      <el-radio-group v-model="info.visitMode">
        <el-radio label="1">门诊</el-radio>
        <el-radio label="2">家庭</el-radio>
        <el-radio label="3">电话</el-radio>
      </el-radio-group>
    </div>
    <p style="font-weight: 900; font-size: 20px; color: #000">生存信息</p>
    <div class="box">
      <span>生存状态：</span>
      <el-radio-group v-model="info.shengcunzhuangtai">
        <el-radio label="存活">存活</el-radio>
        <el-radio label="死亡">死亡</el-radio>
        <el-radio label="没联系上">没联系上</el-radio>
      </el-radio-group>
    </div>
    <div class="box">
      <span>最后接触时间时间：</span>
      <el-date-picker
        v-model="info.zuihoujiechushijian"
        align="right"
        type="date"
        placeholder=""
        :picker-options="pickerOptions"
        size="small"
      >
      </el-date-picker>
    </div>
    <div class="box">
      <span>死亡原因分类：</span>
      <el-input
        placeholder=""
        v-model="info.siwangyuanyinfenlei"
        style="width: 300px"
        size="small"
      >
      </el-input>
    </div>
    <div class="box">
      <span>根本死亡原因：</span>
      <el-select v-model="info.genbensiwangyuanyin" placeholder="" size="small">
        <el-option label="肿瘤" value="肿瘤"> </el-option>
        <el-option label="非肿瘤" value="非肿瘤"> </el-option>
        <el-option label="不详" value="不详"> </el-option>
      </el-select>
    </div>
    <div class="box">
      <span>死亡医学证书名编号：</span>
      <el-input
        placeholder=""
        v-model="info.siwangyixuezhengshumingbianhao"
        style="width: 300px"
        size="small"
      >
      </el-input>
    </div>
    <div class="box">
      <span>死亡地点：</span>
      <el-select v-model="info.siwangdidian" placeholder="" size="small">
        <el-option label="医院病房" value="医院病房"> </el-option>
        <el-option label="急诊室" value="急诊室"> </el-option>
        <el-option label="家中" value="家中"> </el-option>
        <el-option label="外地" value="外地"> </el-option>
        <el-option label="家庭病床" value="家庭病床"> </el-option>
        <el-option label="敬老院" value="敬老院"> </el-option>
        <el-option label="来院已死" value="来院已死"> </el-option>
        <el-option label="其他" value="其他"> </el-option>
        <el-option label="不详" value="不详"> </el-option>
      </el-select>
    </div>
    <p style="font-weight: 900; font-size: 20px; color: #000">治疗信息</p>
    <div class="box">
      <span>治疗情况：</span>
      <el-select v-model="info.zhiliaoqingkuang" placeholder="" size="small">
        <el-option label="未治疗" value="未治疗"> </el-option>
        <el-option label="治疗" value="治疗"> </el-option>
        <el-option label="不明" value="不明"> </el-option>
      </el-select>
    </div>
    <p style="font-weight: 900; font-size: 20px; color: #000">肿瘤信息</p>
    <div class="box">
      <span>确认肿瘤：</span>
      <el-radio-group v-model="info.querenzhongliu">
        <el-radio label="1">是</el-radio>
        <el-radio label="2">确认非肿瘤</el-radio>
      </el-radio-group>
    </div>
    <p style="font-weight: 900; font-size: 20px; color: #000">随访属性</p>
    <div class="box">
      <span>随访备注：</span>
      <el-input
        placeholder=""
        type="textarea"
        v-model="info.suifangbeizhu"
        style="width: 500px"
        :rows="5"
        size="small"
      >
      </el-input>
    </div>
  </div>
</template>
        
        <script>
export default {
  data() {
    return {
      info: {
        hospitalId: window.localStorage.getItem("hospitalId"),
        idNo: localStorage.getItem("idCard"),
        residentName: window.localStorage.getItem("residentName"),
        createUserId: window.localStorage.getItem("doctorName"),
        symptom: [],
        staging: [],
        signFootArterial: [],
        insulinCount: [],
        childsItems: [],
        //   insulinItems: [],
      },
      options: [
        {
          value: "测试",
          label: "测试",
        },
      ],
      pickerOptions: {
        shortcuts: [
          {
            text: "今天",
            onClick(picker) {
              picker.$emit("pick", new Date());
            },
          },
        ],
      },
      isLoading: false,
      restaurants: [],
      queryString: "",
      isTopDialog: false,
    };
  },
  mounted() {
    if (this.sf_flag == 2) {
      this.info.typeChildDetail = 1;
    }
    if (this.sf_flag == 3) {
      this.info.typeChildDetail = 0;
    }
    this.set_form();
  },
  props: {
    sf_flag: { type: Number, default: 0 },
  },
  methods: {
    btn_ok() {
      var url = this.info.id ? "/mbSfZl/Update" : "/mbSfZl/Insert";
      this.info.symptom = this.info.symptom.toString();
      this.info.staging = this.info.staging.toString();
      this.info.signFootArterial = this.info.signFootArterial.toString();
      this.info.insulinCount = this.info.insulinCount.toString();
      var date = new Date();
      this.info.id
        ? (this.info.updatetime = date)
        : (this.info.createtime = date);
      this.$post(url, this.info).then((res) => {
        if (res.code == 400) {
          this.$message({
            message: res.message,
            type: "error",
          });
          return;
        }
        this.$message({
          message: "操作成功",
          type: "success",
        });
      });
    },
    getInfo(item, flag) {
      this.isLoading = true;
      this.getOne(item.id, flag);
    },
    getOne(id, flag) {
      this.$post("/mbSfZl/getOne?id=" + id).then((res) => {
        this.info = res.data;
        this.info.signFootArterial = this.info.signFootArterial
          ? this.info.signFootArterial.split(",")
          : [];
        this.info.symptom = this.info.symptom
          ? this.info.symptom.split(",")
          : [];
        this.info.staging = this.info.staging
          ? this.info.staging.split(",")
          : [];
        this.info.insulinCount = this.info.insulinCount.split(",");
        this.isLoading = false;
        if (flag == "预览") {
          this.isTopDialog = true;
        }
      });
    },
    set_form() {
      this.isLoading = true;
      var d = new Date();
      d.setMonth(d.getMonth() + 3);
      var yy1 = d.getFullYear();
      var mm1 = d.getMonth() + 1; //因为getMonth（）返回值是 0（一月） 到 11（十二月） 之间的一个整数。所以要给其加1
      var dd1 = d.getDate();
      if (mm1 < 10) {
        mm1 = "0" + mm1;
      }
      if (dd1 < 10) {
        dd1 = "0" + dd1;
      }
      this.info.visitDate = new Date();
      this.info.nextDate = yy1 + "-" + mm1 + "-" + dd1;
      this.info.executorName = window.localStorage.getItem("doctorName");
      this.info.unitName = window.localStorage.getItem("hospitalName");
      this.isLoading = false;
    },
    clear_info() {
      this.info = {
        hospitalId: "3015",
        idNo: localStorage.getItem("idCard"),
        residentName: "",
        symptom: [],
        staging: [],
        signFootArterial: [],
        insulinCount: [{}],
        childsItems: [],
        //   insulinItems: [],
      };
    },
    querySearch(queryString, cb) {
      if (!queryString) {
        return;
      }
      this.queryString = queryString;
      this.getYao();
      setTimeout((_) => {
        cb(this.restaurants);
      }, 500);

      // 调用 callback 返回建议列表的数据
    },
    handleSelect(item) {},
    getYao(val) {
      this.$get(
        baseUrl.mbIp + "/api/His/GetMedicineList/" + this.queryString
      ).then((res) => {
        var arr = [];
        for (var i in res.Data) {
          arr.push(res.Data[i]);
          arr[i].value = arr[i].drug_name;
        }
        this.restaurants = arr;
      });
    },
    sum_tz() {
      if (!this.info.height || !this.info.signWeight) {
        return;
      }
      this.isLoading = true;
      this.info.signBmi = this.toBmi(this.info.height, this.info.signWeight);
      this.isLoading = false;
    },
    sum_tz2() {
      if (!this.info.height || !this.info.targetWeight) {
        return;
      }
      this.isLoading = true;
      this.info.targetBmi = this.toBmi(
        this.info.height,
        this.info.targetWeight
      );
      this.isLoading = false;
    },
    toBmi(height, weight) {
      var height2 = height / 100;
      var sum = 0;
      sum = weight / (height2 * height2);
      return Math.round(sum * 100) / 100;
    },
  },
};
</script>
        
        <style scoped lang="scss">
.tnbhzsf {
  .top {
    padding: 10px 20px;
    background-color: #e6f7ff;
    border: 1px solid #91d5ff;
  }
  .tab1 {
    tr {
      width: 100%;
      th {
        text-align: center;
        color: #000;
        background-color: rgb(250, 250, 250);
      }
      td {
        padding: 10px;
      }
    }
  }
  .box {
    padding: 10px 250px;
    background-color: rgb(250, 250, 250);
    margin: 10px 0;
  }
}
.table_rd_pd {
  th,
  td {
    padding: 5px 10px;
  }
}
.pointer {
  pointer-events: none;
}
</style>